<template>
  <el-dialog :visible.sync="value" :before-close="cancel" append-to-body>
    <div class="createPost-container" style="max-height:60vh; overflow: auto;padding:10px;">
      <el-row>
        <el-col>
          <div class="grid-content bg-purple">{{this.form.sendTime | toTime}}</div>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <div class="grid-content bg-purple">
            <span class="tips">发至层级:</span>
            {{this.form.memberLevelName}}
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <div class="grid-content bg-purple">
            <span class="tips">发送会员:</span>
            <span class="sned-member">{{this.form.memberAccount}}</span>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <div class="grid-content bg-purple">
            <span class="tips">标题:</span>
            {{this.form.title}}
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <div class="grid-content bg-purple">
            <span class="tips">正文:</span>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <div class="content" v-html="this.form.content"></div>
      </el-row>
    </div>
  </el-dialog>
</template>

<script>
import { noticePostboxCheckLetterApi } from '@/services/api/notice';
import { form } from '@/build';

export default {
  name: 'check-notice-letter',
  components: {},
  mixins: [form],
  props: ['value', 'id', 'rowData'],

  data() {
    return {
      form: {
        id: String(this.id),
        memberLevelName: '',
        memberAccount: '',
        content: '',
        title: '',
        sendTime: '',
        lastOperator: '',
      },
    };
  },
  computed: {},
  props: ['value', 'id', 'rowData'],
  mounted() {
    // if (!_.isUndefined(this.rowData) && this.rowData.id) {
    //   console.log(this.rowData);
    //   let { memberLevelId, sendTime } = this.rowData;
    //   this.form = {
    //     ...this.rowData,
    //     sendTime: new Date(sendTime)
    //   };
    // }
    this.bindGet(noticePostboxCheckLetterApi, 'form', {
      action: 'getGrid',
      sendingData: { id: String(this.id) },
    });
    this.getAll();
  },
  methods: {
    cancel() {
      this.$emit('input', false);
    },
    // 去掉富文本的标签
    toRemoveHtml(str) {
      if (str) {
        str.replace(/<[^>]+>/g, '');
      }
      return str;
    },
  },
};
</script>

<style lang="scss" scoped>
.createPost-container{
  overflow: auto;
}
.image {
  width: 100px;
  height: 100px;
}
.el-col {
  border-radius: 4px;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
  max-width: 500px;
  word-wrap: break-word;
  padding: 5px 0;
}
.sned-member {
  min-width: 200px;
  max-width: 500px;
  word-wrap: break-word;
}
.content {
  color: #000;
  min-width: 300px;
  max-width: 600px;
  word-wrap: break-word;

}
.tips{
  color: #000;
  font-weight: bold;
  padding-right:8px;
}
</style>
